﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:local="clr-namespace:NETXPF.WPF"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    
    <!--Colors section-->
    <SolidColorBrush x:Key="SolidBlack" Color="Black"/>
    <SolidColorBrush x:Key="SolidSilver" Color="Silver"/>
    <SolidColorBrush x:Key="SolidWhite" Color="White"/>
    
    <Style x:Key="ExpandCollapseToggleStyle"
			TargetType="{x:Type ToggleButton}">
        <Setter Property="Focusable"
					Value="False"/>
        <Setter Property="Width"
					Value="19"/>
        <Setter Property="Height"
					Value="13"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ToggleButton}">
                    <Border Width="19"
								Height="13">
                        <Border Width="9"
									Height="9"
									CornerRadius="1"
									SnapsToDevicePixels="true"
                  Background="{StaticResource SolidSilver}">
                            <Path x:Name="ExpandPath"
									  Margin="2,1,1,1"
									  Fill="{StaticResource SolidWhite}"
									  Data="M 0 2 L 0 3 L 2 3 L 2 5 L 3 5 L 3 3 L 5 3 L 5 2 L 3 2 L 3 0 L 2 0 L 2 2 Z"/>
                        </Border>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsChecked"
									 Value="True">
                            <Setter Property="Data"
										TargetName="ExpandPath"
										Value="M 0 2 L 0 3 L 5 3 L 5 2 Z"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!--Style for the TreeListBoxItem-->
    <Style TargetType="{x:Type local:TreeListBoxItem}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type local:TreeListBoxItem}">
                    <Border Name="Bd"
                      Background="{TemplateBinding Background}"
                      BorderBrush="{TemplateBinding BorderBrush}"
                      BorderThickness="{TemplateBinding BorderThickness}"
                      Padding="{TemplateBinding Padding}">
                        <WrapPanel DataContext="{Binding RelativeSource={RelativeSource AncestorType={x:Type local:TreeListBoxItem}}}">
                            <!--Button to show the + sign-->
                            <ToggleButton x:Name="PART_Header"
                              Style="{StaticResource ExpandCollapseToggleStyle}"
                              ClickMode="Press"/>
                            <ContentPresenter />
                        </WrapPanel>
                    </Border>

                    <ControlTemplate.Triggers>
                        <Trigger Property="IsSelected"
									 Value="true">
                            <Setter TargetName="Bd"
										Property="Background"
										Value="{DynamicResource {x:Static SystemColors.HighlightBrushKey}}"/>
                            <Setter Property="Foreground"
										Value="{DynamicResource {x:Static SystemColors.HighlightTextBrushKey}}"/>
                        </Trigger>
                        <Trigger Property="IsEnabled"
									 Value="false">
                            <Setter Property="Foreground"
										Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
                        </Trigger>
                    </ControlTemplate.Triggers>

                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    
</ResourceDictionary>